package at.com.vn.chess.bean;

import java.util.ArrayList;

import at.com.vn.chess.dao.UserDao;
import at.com.vn.chess.entity.User;

public class UserBean {

	ArrayList<User> lstUser;

	public ArrayList<User> getLstUser() {
		return lstUser;
	}

	public void setLstUser(ArrayList<User> lstUser) {
		this.lstUser = lstUser;
	}

	public User getUserValid(User fromUser) {
		UserDao userDao = new UserDao();
		userDao.beginTrans();
		for (User iUser : userDao.findAllUser()) {
			if (iUser.getUser_id().trim().equals(fromUser.getUser_id().trim())
					&& iUser.getUser_password().trim()
							.equals(fromUser.getUser_password().trim())) {
				userDao.closeTrans();
				return iUser;
			}
		}
		userDao.closeTrans();
		return null;
	}

	public Boolean isNotLogin(User user, ArrayList<User> userList) {
		for (User iUser : userList) {
			if (iUser.getUser_id().trim().equals(user.getUser_id().trim())) {
				return false;
			}
		}
		return true;
	}

}
